package com.lxy.cxcyxmmsbackend.sys.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket1() {
        return new Docket(DocumentationType.SWAGGER_2).groupName("A");
    }

    //配置swagger实例
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(true) //是否启用swagger
                .groupName("cxcyxm")
                .select()
                //配置要扫描接口的方式
                //指定要扫描的包basePackage()
                //any() 全部
                //none() 都不
                //withClassAnnotation() :扫描类上的注解
                //withMethodAnnotation() :扫描方法上的注解
                .apis(RequestHandlerSelectors.basePackage("com.lxy.cxcyxmmsbackend.sys.controller"))
//                .paths(PathSelectors.ant("/lxy/**")) //过滤扫描路径
                .build();
    }

    //配置swagger类 apiinfo
    private ApiInfo apiInfo() {
        return new ApiInfo("效能平台项目管理系统",
                "Swagger接口文档",
                "v1.0",
                "",
                new Contact("刘新颖", "",
                        "2459131972@qq.com"), //作者信息
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList<>());
    }
}
